package ED;

import net.datastructures.Edge;
import net.datastructures.Entry;
import net.datastructures.HashTableMap;
import net.datastructures.InvalidKeyException;
import net.datastructures.Map;
import net.datastructures.Position;
import net.datastructures.Vertex;

/**
 * Implementacion de aristas 
 * 
 * @author Sebastian Giulietti 69032 
 * @author Adrian Sanchez 64251
 *
 * @param <E> Tipo de dato de los vertices
 * @param <M> Tipo de dato de las aristas
 */
public class MyEdge<E, M> implements Edge<M> {

	private Vertex<E> destino;
	private M element;
	private Map<Object, Object> map;
	private Vertex<E> origen;
	private Position<Edge<M>> position;
	private boolean visitado;

	/**
	 * Constructor
	 */
	public MyEdge() {
		map = new HashTableMap<Object, Object>(10);
	}

	/**
	 * Agrega el rotulo
	 * @param e rotulo
	 */
	public void addRotulo(M e) {
		element = e;
	}

	@Override
	public M element() {
		return element;
	}

	@Override
	public Iterable<Entry<Object, Object>> entries() {
		return map.entries();
	}

	@Override
	public Object get(Object key) throws InvalidKeyException {
		return map.get(key);
	}

	public Vertex<E> getDestino() {
		return destino;
	}

	public M getElement() {
		return element;
	}

	public Vertex<E> getOrigen() {
		return origen;
	}

	public Position<Edge<M>> getPosition() {
		return position;
	}

	public boolean getVisitado() {
		return visitado;
	}

	@Override
	public boolean isEmpty() {
		return map.isEmpty();
	}

	@Override
	public Iterable<Object> keys() {
		return map.keys();
	}

	@Override
	public Object put(Object key, Object value) throws InvalidKeyException {
		return map.put(key, value);
	}

	@Override
	public Object remove(Object key) throws InvalidKeyException {
		return map.remove(key);
	}

	public void setDestino(Vertex<E> destino) {
		this.destino = destino;
	}

	public void setElement(M element) {
		this.element = element;
	}

	public void setOrigen(Vertex<E> origen) {
		this.origen = origen;
	}

	public void setPosition(Position<Edge<M>> position2) {
		this.position = position2;
	}

	public void setVisitado(boolean visitado) {
		this.visitado = visitado;
	}

	@Override
	public int size() {
		return map.size();
	}

	@Override
	public String toString() {
		return "MyEdge->" + element().toString();
	}

	@Override
	public Iterable<Object> values() {
		return map.values();
	}

}
